home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-23 | 4.7 KB | 107 lines | [TEXT/ttxt] |
- 11 MacDOS Extensions
- You can extend the functionality of MacDOS by creating your
- own "pipable" filter applications. Such applications accept
- as input the output of MacDOS commands and send their
- results back to MacDOS for display in the console window.
-
- To work as a filter, an application must:
- • Be of type 'APPL' and creator 'mFLR'.
- • Be able to run in the background.
- • Support the MacDOS communication protocol to exchange
- messages with other processes.
-
- This section only describes how to use filters that already
- exist. If you are interested in creating your own new
- filters, please refer to Appendix B.
-
- Basically, there are two ways in which you can use filters
- within the command line:
-
- filter1 < inFile
-
- or
-
- command | filter1
-
- In the first case, a text file is fed into filter1, while
- in the second case, the output of a MacDOS command is sent
- to filter1. In both examples, the output of filter1 is sent
- to the console window.
-
- Commands and filters have in general one or more switches.
- Also note that the position of file redirection within the
- command line is irrelevant: output redirection
- automatically applies to the last (ie. rightmost) filter
- and input redirection to the first one.
-
- Some examples of valid chains of commands and filters are:
-
- filter1 <inFile >outFile | filter2
- Data flow: inFile -> filter1 -> filter2 ->
- outFile
-
- filter1 | filter2 <inFile
- Data flow: inFile -> filter1 -> filter2 ->
- console
-
- dir /b/a-d | myFilter mode1 >outFile
- Data flow: MacDOS -> myFilter -> outFile.
- DIR sends its output to myFilter and myFilter executes
- with the "mode1" option.
-
- \filterDir\filter1 <inFile | more
- Data flow: inFile -> filter1 -> console
- MacDOS pages the output of filter1 to the console
- window
-
- help filter1 | aSubDir\filter2 | filter3
- Data flow: MacDOS -> filter2 -> filter3 -> console
- MacDOS sends to filter2 the help information provided
- by filter1. The output of filter2 is processed by
- filter3 before being sent to the console window.
-
- A chain must satisfy the following conditions:
- • A filter can appear anywhere (at the beginning, between
- other filters separated by pipes, and at the end), but
- if it appears at the beginning, the command line must
- include input redirection (note: filter < inFile is
- completely equivalent to type inFile | filter).
- • MORE can only appear in the last position of a chain.
- • MacDOS commands (with the exception of MORE) can only
- appear at the beginning of a chain.
-
- Note that MacDOS searches the table of internal commands
- before looking for filters. Therefore, filters named like
- commands can only be executed if they are preceded by a
- path.
-
- You should normally be able to get help on MacDOS filters
- by typing "help filterName" ("filterName/?" is not
- supported).
-
- Filters and the Finder
- If you launch a filter application by double clicking on
- it, you can ONLY terminate it by making it the frontmost
- application and typing CNTL-C (or CMD-dot). Note that the
- shutdown will not work, because filters do not accept the
- standard AEs. This was done to reduce filter code to the
- minimum.
-
- Speed of filters
- You will find that filters are quite slow, especially with
- less powerful Macs. That is, as soon as you pipe data
- through a filter, the console window scrolls significantly
- slower. This is mainly due to the process switches that the
- Mac OS has to perform before a message goes through all the
- pipes and back to MacDOS. As a result of this, you will
- probably decide to use MacDOS pipes only to filter files
- and commands with a low number of lines or to perform
- operations in the background while you do something else.
-
- After sending a message to the first filter of a chain,
- MacDOS expects to receive a message from the last filter.
- By default, MacDOS reports a timeout error if it fails to
- receive the message after 2 seconds. You can change this
- timeout by setting the global variable TIMEOUT to the
- appropriate number of seconds.
-